/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import utility.Utility;

/**
 *
 * @author Reinhard
 */
public class Server {

  public static void main(String[] args) throws IOException {
    boolean listening = true;
    int port = 4000;
    ServerSocket serverSocket = null;

    
    try {
    serverSocket = new ServerSocket(Utility.SERVER_PORT);
    } catch (IOException ex) {
    ex.printStackTrace();
    }

    while (listening) {
//      boolean portAvailable = false;
//      while (!portAvailable) {
//        try {
//          serverSocket = new ServerSocket(port);
//        } catch (IOException e) {
//          ++port;
//        } finally {
//          portAvailable = true;
//        }
//      }
//      System.out.println("Port take : "+port);
      new ServerThread(serverSocket).start();
    }

    serverSocket.close();
  }
}
